package cetcbigdata.da.service.zhejiang.qitaqingdan;

import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;


/**
 * @author YuanGongPing
 * @version 0.1
 * @description Js
 * @since 2022/8/3 17:28
 */


public class Js {
    public static String jsCode = "" +
            "var _0x5e8b26 = '3000176000856006061501533003690027800375'\n" +
            "\n" +
            "var getAcwScV2 = function (arg1) {\n" +
            "   String['prototype']['hexXor'] = function (_0x4e08d8) {\n" +
            "      var _0x5a5d3b = '';\n" +
            "      for (var _0xe89588 = 0x0; _0xe89588 < this['length'] && _0xe89588 < _0x4e08d8['length']; _0xe89588 += 0x2) {\n" +
            "         var _0x401af1 = parseInt(this['slice'](_0xe89588, _0xe89588 + 0x2), 0x10);\n" +
            "         var _0x105f59 = parseInt(_0x4e08d8['slice'](_0xe89588, _0xe89588 + 0x2), 0x10);\n" +
            "         var _0x189e2c = (_0x401af1 ^ _0x105f59)['toString'](0x10);\n" +
            "         if (_0x189e2c['length'] == 0x1) {\n" +
            "            _0x189e2c = '0' + _0x189e2c;\n" +
            "         }\n" +
            "         _0x5a5d3b += _0x189e2c;\n" +
            "      }\n" +
            "      return _0x5a5d3b;\n" +
            "   };\n" +
            "   String['prototype']['unsbox'] = function () {\n" +
            "      var _0x4b082b = [0xf, 0x23, 0x1d, 0x18, 0x21, 0x10, 0x1, 0x26, 0xa, 0x9, 0x13, 0x1f, 0x28, 0x1b, 0x16, 0x17, 0x19, 0xd, 0x6, 0xb, 0x27, 0x12, 0x14, 0x8, 0xe, 0x15, 0x20, 0x1a, 0x2, 0x1e, 0x7, 0x4, 0x11, 0x5, 0x3, 0x1c, 0x22, 0x25, 0xc, 0x24];\n" +
            "      var _0x4da0dc = [];\n" +
            "      var _0x12605e = '';\n" +
            "      for (var _0x20a7bf = 0x0; _0x20a7bf < this['length']; _0x20a7bf++) {\n" +
            "         var _0x385ee3 = this[_0x20a7bf];\n" +
            "         for (var _0x217721 = 0x0; _0x217721 < _0x4b082b['length']; _0x217721++) {\n" +
            "            if (_0x4b082b[_0x217721] == _0x20a7bf + 0x1) {\n" +
            "               _0x4da0dc[_0x217721] = _0x385ee3;\n" +
            "            }\n" +
            "         }\n" +
            "      }\n" +
            "      _0x12605e = _0x4da0dc['join']('');\n" +
            "      return _0x12605e;\n" +
            "   };\n" +
            "   var _0x23a392 = arg1['unsbox']();\n" +
            "   arg2 = _0x23a392['hexXor'](_0x5e8b26);\n" +
            "   return arg2\n" +
            "};\n" +
            "\n" +
            "\n";
    public static String getEncode(String arg1){
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine engine = manager.getEngineByName("js");
        //编写js方法体
        try {
            engine.eval(jsCode);
            //执行js脚本。
            Invocable invocable = (Invocable) engine;
            Object object = invocable.invokeFunction("getAcwScV2", arg1);
            return object.toString();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;

    }

}
